#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> summaryRanges(vector<int>& nums) 
{
    vector<string> ret;
    int i = 0;
    int n = nums.size();
    while (i < n) 
    {
        int low = i;
        i++;
        while (i < n && nums[i] == nums[i - 1] + 1) 
        {
            i++;
        }
        int high = i - 1;
        string temp = to_string(nums[low]);
        if (low < high) 
        {
            temp += "->";
            temp += to_string(nums[high]);
        }
        ret.push_back(move(temp));
    }
    return ret;
}

int main()
{
	vector<int> v = { 0,1,2,4,5,7 };
	vector<string> ret = summaryRanges(v);
	for (int i = 0; i < ret.size(); i++)
	{
		cout << ret[i] << " ";
	}
	return 0;
}